package com.dinetech.dao;

import java.util.ArrayList;
import java.util.List;

import com.dinetech.entidades.Evento;
import com.dinetech.entidades.Session;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.view.ViewGroup;

public class EventoPagerAdapter  extends FragmentPagerAdapter{

	List<Fragment> eventos;
	ArrayList<Evento> listit;
	
	public EventoPagerAdapter(FragmentManager fm) {
		super(fm);
		this.eventos = new ArrayList<Fragment>();
	}

	public void addEventoFragment(Fragment fragment) {
		this.eventos.add(fragment);
	}
	
	@Override
	public Fragment getItem(int location) {
		
		return this.eventos.get(location);
	}

	@Override
	public int getCount() {
		
		return this.eventos.size();
	}
	
	@Override
	public CharSequence getPageTitle(int position) {
		Session se=  Session.getInstance();
		String tituloPagina="";
		
		if(se.getNIVEL_EVENTO() == 1){
			
			listit = se.getLISTA_EVENTO();
			
		}else if(se.getNIVEL_EVENTO() == 2){
			
			listit = se.getLISTA_EVENTO_REPRODUCTOR();
			
		}
		
		if(position == listit.size()){
			tituloPagina ="Baja";
			
		}else{
			tituloPagina = listit.get(position).getNombreEvento();
		}
		
		return tituloPagina ;
	}

	@Override
	public void destroyItem(ViewGroup container, int position, Object object) {
		//((ViewPager)container).removeView((LinearLayout)object);

	}
	

}
